From f45785b56c90f81a601956fe46d58fd3cab5109a Mon Sep 17 00:00:00 2001 From: jfatherton Date: Wed, 15 Sep 2004 03:22:57 +0000 Subject: [PATCH] Tidying code, added console logging for easier bug tracking --- gpsbabel/macgpsbabel/MacGPSBabel.applescript | 70 +++++++++++++------ .../MacGPSBabel.pbproj/jeremya.pbxuser | 53 ++++++++++---- 2 files changed, 85 insertions(+), 38 deletions(-) diff --git a/gpsbabel/macgpsbabel/MacGPSBabel.applescript b/gpsbabel/macgpsbabel/MacGPSBabel.applescript index 74182221c..1aee120cc 100644 --- a/gpsbabel/macgpsbabel/MacGPSBabel.applescript +++ b/gpsbabel/macgpsbabel/MacGPSBabel.applescript @@ -26,8 +26,8 @@ on will finish launching theObject end will finish launching on awake from nib theObject + log "awake from nib - " & name of theObject if theObject is window "MacGPSBabel" then - -- get supported file types from gpsbabel and use these to populate the file types popup lists tell window "MacGPSBabel" set popList to my getFormats() @@ -53,7 +53,7 @@ end awake from nib -- Deal with the opening and closing of windows on will open theObject - + log "will open - " & name of theObject -- Main Window if theObject is window "MacGPSBabel" then -- set the progress indicator style @@ -85,6 +85,7 @@ on will open theObject end will open on will close theObject + log "will close - " & name of theObject if theObject is window "SelectGPS" then -- store user defaults for this window set newReceiverIndex to contents of popup button "gpsPop" of window "SelectGPS" as integer @@ -100,6 +101,7 @@ end will close -- handler for the File>Open menu item on choose menu item theObject + log "choose menu item - " & name of theObject if name of theObject is "open" then if visible of window "MacGPSBabel" is true then if contents of text field "inputFile" of window "MacGPSBabel" is equal to "" then @@ -131,6 +133,8 @@ end choose menu item -- HANDLERS FOR BUTTON CLICKS on clicked theObject + log "clicked - " & name of theObject + -- MAIN WINDOW - Select File button if theObject is the button "selectButton" of window "MacGPSBabel" then if contents of text field "inputFile" of window "MacGPSBabel" is equal to "" then @@ -437,22 +441,13 @@ on convertFile(fileList) display dialog "conversion cancelled" buttons {"OK"} default button 1 return 0 end if - feedbackBusy(true) -- do the script set thePath to POSIX path of (path to me) as string set theConvertScript to (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & fileText & " " & filterText & "-o " & outType & " -F " & quoted form of outputFile) as string - try - set scriptOut to do shell script theConvertScript as string - set convertYN to "Conversion Completed Successfully" - on error - set scriptOut to "gpsbabel encountered an error" - set convertYN to "Conversion Failed!" - end try - feedbackBusy(false) - display dialog convertYN buttons {"OK"} default button 1 - if visible of window "debugWindow" is true then - set the contents of text view 1 of scroll view 1 of window "debugWindow" to "" - set the contents of text view 1 of scroll view 1 of window "debugWindow" to "MacGPSBabel Report" & return & return & "The Shell Script:" & return & theConvertScript & return & return & convertYN & return & return & "Output From gpsbabel:" & return & scriptOut + if (my runBabel(theConvertScript)) then + display dialog "File conversion is complete" buttons {"OK"} default button 1 + else + display dialog "Sorry, the file conversion failed" buttons {"OK"} default button 1 end if my clearFiles() end convertFile @@ -508,11 +503,13 @@ on uploadFile(fileList) set thePath to POSIX path of (path to me) as string set visible of window "SelectGPS" to false set visible of window "MacGPSBabel" to true - feedbackBusy(true) set serialText to "-F /dev/cu." & (the title of popup button "serialPop" of window "selectGPS") - do shell script (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & fileText & " " & filterText & "-o " & gpsText & serialText) - feedbackBusy(false) - display dialog "Upload Complete" buttons {"OK"} default button 1 + set theConvertScript to (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & fileText & " " & filterText & "-o " & gpsText & serialText) + if (my runBabel(theConvertScript)) then + display dialog "Upload to" & gpsText & "GPS receiver is complete" buttons {"OK"} default button 1 + else + display dialog "Sorry, upload to" & gpsText & "GPS receiver failed" buttons {"OK"} default button 1 + end if end uploadFile -- deal with downloading files from GPS receiver on downloadFile() @@ -563,15 +560,42 @@ on downloadFile() set serialText to "/dev/cu." & (the title of popup button "serialPop" of window "selectGPS") set visible of window "SelectGPS" to false set visible of window "MacGPSBabel" to true - feedbackBusy(true) - do shell script (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & trackText & " -i" & gpsText & "-f " & serialText & " " & filterText & " -o " & outType & " -F " & quoted form of outputFile) - feedbackBusy(false) - display dialog "Download from GPS is complete" buttons {"OK"} default button 1 + set theConvertScript to (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & trackText & " -i" & gpsText & "-f " & serialText & " " & filterText & " -o " & outType & " -F " & quoted form of outputFile) + if (my runBabel(theConvertScript)) then + display dialog "Download from" & gpsText & "GPS receiver is complete" buttons {"OK"} default button 1 + else + display dialog "Sorry, download from" & gpsText & "GPS receiver failed" buttons {"OK"} default button 1 + end if else set outputFile to "" end if end downloadFile +-- Send the call to gpsbabel +on runBabel(theConvertScript) + log "Tried to execute: " & theConvertScript + set theConvertScript to theConvertScript & " 2>&1" + feedbackBusy(true) + try + set scriptOut to do shell script theConvertScript as string + set babelHappy to true + log "Success! gpsbabel returned: " & scriptOut + on error + set scriptOut to "gpsbabel encountered an error" + set babelHappy to false + log "Error! gpsbabel returned: " & scriptOut + end try + feedbackBusy(false) + if visible of window "debugWindow" is true then + set the contents of text view 1 of scroll view 1 of window "debugWindow" to "" + set the contents of text view 1 of scroll view 1 of window "debugWindow" to "MacGPSBabel Report" & return & return & "The Shell Script:" & return & theConvertScript & return & return & convertYN & return & return & "Output From gpsbabel:" & return & scriptOut + end if + return babelHappy +end runBabel + + + + -- FILTERING HANDLERS -- show filters window on showFilters() diff --git a/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser b/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser index 3089df577..3964792fb 100644 --- a/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser +++ b/gpsbabel/macgpsbabel/MacGPSBabel.pbproj/jeremya.pbxuser @@ -106,7 +106,7 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 116301737; + PBXPerProjectTemplateStateSaveDate = 116907658; PBXPrepackagedSmartGroups_v2 = ( { PBXTransientLocationAtTop = bottom; @@ -918,11 +918,14 @@ WindowLocation = "{4, 381}"; }, ); - PBXWorkspaceStateSaveDate = 116301737; + PBXWorkspaceStateSaveDate = 116907658; }; perUserProjectItems = { - 3F26E6CA06EE9FD000A5ACEA = 3F26E6CA06EE9FD000A5ACEA; - 3FC2F7C606EE9F8B002083D3 = 3FC2F7C606EE9F8B002083D3; + 3F13581706F7DEF5001F6BE7 = 3F13581706F7DEF5001F6BE7; + 3F13583006F7EC6B001F6BE7 = 3F13583006F7EC6B001F6BE7; + 3FB41B8906EFB84A0017502D = 3FB41B8906EFB84A0017502D; + 3FB41B8B06EFB84A0017502D = 3FB41B8B06EFB84A0017502D; + 3FB41B8C06EFB84A0017502D = 3FB41B8C06EFB84A0017502D; }; sourceControlManager = 3F8AAF0806E7E5D400E74F19; userBuildSettings = { @@ -934,15 +937,25 @@ DA206CF0015C4D9F03C91932, ); }; - 3F26E6CA06EE9FD000A5ACEA = { + 3F13581706F7DEF5001F6BE7 = { fRef = DA206CF3015C4E8B03C91932; isa = PBXTextBookmark; name = "MacGPSBabel.applescript: 815"; rLen = 0; - rLoc = 34625; + rLoc = 35444; rType = 0; - vrLen = 1394; - vrLoc = 14697; + vrLen = 1617; + vrLoc = 22605; + }; + 3F13583006F7EC6B001F6BE7 = { + fRef = DA206CF3015C4E8B03C91932; + isa = PBXTextBookmark; + name = "MacGPSBabel.applescript: 839"; + rLen = 0; + rLoc = 35550; + rType = 0; + vrLen = 1415; + vrLoc = 23045; }; 3F8AAF0806E7E5D400E74F19 = { fallbackIsa = XCSourceControlManager; @@ -966,15 +979,25 @@ wantsCodeCompletionTabCompletes = 1; wantsIndex = 1; }; - 3FC2F7C606EE9F8B002083D3 = { + 3FB41B8906EFB84A0017502D = { + fRef = DA206CF4015C4E8B03C91932; + fallbackIsa = PBXBookmark; + isa = ASKDictionaryBookmark; + }; + 3FB41B8B06EFB84A0017502D = { fRef = DA206CF3015C4E8B03C91932; isa = PBXTextBookmark; name = "MacGPSBabel.applescript: 815"; rLen = 0; - rLoc = 34625; + rLoc = 35444; rType = 0; - vrLen = 1409; - vrLoc = 14697; + vrLen = 1617; + vrLoc = 22605; + }; + 3FB41B8C06EFB84A0017502D = { + fRef = DA206CF4015C4E8B03C91932; + fallbackIsa = PBXBookmark; + isa = ASKDictionaryBookmark; }; DA206CF0015C4D9F03C91932 = { activeArgIndex = 2147483647; @@ -1003,9 +1026,9 @@ }; DA206CF3015C4E8B03C91932 = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1672, 12225}}"; - sepNavSelRange = "{34625, 0}"; - sepNavVisRect = "{{0, 4905}, {862, 533}}"; + sepNavIntBoundsRect = "{{0, 0}, {1672, 12585}}"; + sepNavSelRange = "{35550, 0}"; + sepNavVisRect = "{{0, 8145}, {862, 533}}"; }; }; } -- 2.30.2